I am trying to use a transtaction using following code (as indicated in docs):
router.patch('/:locationId(\\d+)', asyncWrap(async (req, res, next) => {
const { locationId } = req.params
const locations = await Locations.transaction(knex, async trx => { // ERROR!
const locations = await Locations
.query(trx)
.patch(req.body)
.findById(locationId)
.returning('*')
return locations
})
return res.json(locations)
}))
But I get the following error:
(knexOrTrx || this.knex(...)).transaction is not a function